import {
	createRouter,
	createWebHashHistory
} from 'vue-router'
import MainHome from '@/views/MainHome.vue'
import AddArticle from '@/views/AddArticle.vue'
import Login from '@/views/Login.vue'
import ShowArticle from '@/components/ShowArticle.vue'

const routes = [
	{
		path: '/',
		name: 'MainHome',
		component: MainHome
	},
	{
		path: '/mainhome',
		name: 'MainHome',
		component: MainHome
	},
	{
		path: '/addarticle',
		name: 'AddArticle',
		component: AddArticle
	},
	{
		path: '/login',
		name: 'Login',
		component: Login
	},
	{
		path: '/showarticle',
		name: 'ShowArticle',
		component: ShowArticle,
		meta:{
			title:'文章'
		}
	},
]

const router = createRouter({
	history: createWebHashHistory(process.env.BASE_URL),
	routes
})

router.beforeEach((to, from, next) => {
	window.document.title = to.meta.title == undefined?'早睡蛋Blog':to.meta.title
	next()

})

export default router
